#include <iostream>
#include <string>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "command.hpp"

using namespace std;

int main()
{
    Init pipe;

    // 打开信道
    int fd = open(FIFO_FILE, O_RDONLY);
    if (fd < 0)
    {
        perror("open");
        exit(FIFO_OPEN_ERR);
    }

    // 开始通信
    while (true)
    {
        char buffer[1024] = {0};
        int n = read(fd, buffer, sizeof(buffer));
        if (n > 0)
        {
            buffer[n] = '\0';
            cout << "client : " << buffer << endl;
        }
    }

    close(fd);
    return 0;
}